#include <WinTen.h>
#include <Windows.h>
#include <extend.h>

//----------------------------------------------------------------------------//

CLIPPER WNDCENTER()
{
   HWND hWnd    = ( HWND ) _parnl( 1 );
   HWND hParent = ( HWND ) _parnl( 2 );
   RECT rctWindow, rctDesktop;
   WORD wLeft, wTop, wWidth, wHeight, wParentWidth, wParentHeight;
   POINT pt;

   GetWindowRect( hWnd, &rctWindow );
   if( hParent && IsWindow( hParent ) )
      GetWindowRect( hParent, &rctDesktop );
   else
      GetWindowRect( GetDesktopWindow(), &rctDesktop );

   wWidth  = rctWindow.right - rctWindow.left;
   wHeight = rctWindow.bottom - rctWindow.top;
   wParentWidth  = rctDesktop.right - rctDesktop.left;
   wParentHeight = rctDesktop.bottom - rctDesktop.top;
   wLeft = rctDesktop.left + ( wParentWidth / 2 ) - ( wWidth / 2 );
   wTop  = rctDesktop.top + ( wParentHeight / 2 ) - ( wHeight / 2 );

   if( hParent )
   {
      pt.x = wLeft;
      pt.y = wTop;
      ScreenToClient( hParent, &pt );
      wLeft = pt.x;
      wTop  = pt.y;
   }

   MoveWindow( hWnd, wLeft, wTop, wWidth, wHeight, TRUE );
}

//----------------------------------------------------------------------------//

CLIPPER SETACTIVEW() // INDOW()   hWnd  --> hWndPrev
{
   _retnl( ( LONG ) SetActiveWindow( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER SETWINDOWO() // RG()
{
   POINT pt;
   DWORD dw = SetWindowOrgEx( ( HWND ) _parnl( 1 ), _parni( 2 ), _parni( 3 ),
                              &pt );

   _reta( 2 );
   _storni( LOWORD( dw ), -1, 1 );
   _storni( HIWORD( dw ), -1, 2 );
}

//----------------------------------------------------------------------------//
